package echat.future.cn.echat.my.view;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import echat.future.cn.echat.R;
import echat.future.cn.echat.databinding.ActivityValueBinding;
import echat.future.cn.echat.my.api.UserApi;
import echat.future.cn.echat.my.utils.HttpUtilsRequst;
import echat.future.cn.echat.my.utils.UserHelper;
import echat.future.cn.echat.my.weight.Navagation.AdapterNavagation;
import echat.future.cn.echat.my.weight.Navagation.IBaseNavagation;

public class ValueActivity extends BaseActivity<ActivityValueBinding>{

    @Override
    public int layoutId() {
        return R.layout.activity_value;
    }

    @Override
    public IBaseNavagation navagation() {
        return new AdapterNavagation(this).setTitle("价值申请", 16, R.color.white).setBack(R.drawable.btn_back).setNavagationBackgroudColor(R.color.color_161823);
    }

    @Override
    public void initView() {
        bind.submit.setOnClickListener(v -> setValue());
    }


    public void setValue(){
        try{
            Integer.parseInt(bind.price.getText().toString());
        }catch (Exception e){
            toast("请输入正确的金额");
            return;
        }
        new HttpUtilsRequst<String>(this,HttpUtilsRequst.retrofitClient.create(UserApi.class).aplyPrice(UserHelper.getToken(),Integer.parseInt(bind.price.getText().toString())))
                .setmOnRequstSuccessListener(new HttpUtilsRequst.OnRequstSuccessListener() {
                    @Override
                    public void onSuccss(Object o) {
                        setResult(RESULT_OK);
                        finish();
                    }
                })
                .start();
    }

}
